<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chkGametype = chkGametype($gametype);
$chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
if ($g_gametype_3d[$gametype]['type'] == 3)
{
    $g_betname_3or5 = $g_betname_5h[$gametype];
    $_5hFlag = true;
}
elseif ($g_gametype_3d[$gametype]['type'] == 4)
{
    $g_betname_3or5 = $_sb_Arr;
    $_5hFlag = false;
}
else
{
    $g_betname_3or5 = judge_type($gametype);
    $_5hFlag = false;
}
unset($chk);
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$ui = new UI_3D(true);
$tpl = new Template2();
require_once( "class_3d/Amounts_3d.php" );
require_once( "class_5h/Amounts_5h.php" );
require_once( "class_sb/Amounts_sb.php" );
if ($_5hFlag)
    $Amounts_3d = new Amounts_5h($gametype);
elseif ($g_gametype_3d[$gametype]['type'] == 4)
	$Amounts_3d = new Amounts_sb($gametype);	
else
    $Amounts_3d = new Amounts_3d($gametype);
$alertmsg = "";
if (isset($_POST['pass']) && getvar("pass") != "")
{
    $fields = array();
    $fields['pass'] = "'" . md5(getvar("pass")) . "'";
    db_update("k_user", $fields, "id=" . $curruser['id']);
    $alertmsg = "更改密码成功！";
}
$list = "";
$rs = $Amounts_3d->getAmountsRsById($curruser['id']);
$backTDList = "";
$disk1Flag = false;
$disk2Flag = false;
$disk3Flag = false;
$disk4Flag = false;
$listNullTd = "";
$colspanI = 3;
$diskArr = array();
if ($curruser['disk1'] == 1)
{
    array_push($diskArr, "A");
    $backTDList .= "<td>A 盘退水</td>";
    $disk1Flag = true;
    $listNullTd .= "<td nowrap align=\"right\"> - </td>";
    ++$colspanI;
}
if ($curruser['disk2'] == 1)
{
    array_push($diskArr, "B");
    $backTDList .= "<td>B 盘退水</td>";
    $disk2Flag = true;
    $listNullTd .= "<td nowrap align=\"right\"> - </td>";
    ++$colspanI;
}
if ($curruser['disk3'] == 1)
{
    array_push($diskArr, "C");
    $backTDList .= "<td>C 盘退水</td>";
    $disk3Flag = true;
    $listNullTd .= "<td nowrap align=\"right\"> - </td>";
    ++$colspanI;
}
if ($curruser['disk4'] == 1)
{
    array_push($diskArr, "D");
    $backTDList .= "<td>D 盘退水</td>";
    $disk4Flag = true;
    $listNullTd .= "<td nowrap align=\"right\"> - </td>";
    ++$colspanI;
}
if (0 < count($diskArr))
{
    $currDisk = implode(" + ", $diskArr) . " 盘";
}
else
{
    $currDisk = "--";
}
$data=array();
if($gametype>=11 && $gametype<=20)
	$order=array(55=>0,0=>1,69=>2,70=>3,1=>4,2=>5,3=>6,56=>7,57=>7,58=>7,59=>8,60=>8,61=>8,4=>9,7=>9,10=>9,5=>10,8=>10,11=>10);
else
	$order=array();
while (!$rs->eof)
{
	$item=$rs->f;
	$item['order']=(isset($order[$rs->f['bettype']])?$order[$rs->f['bettype']]:99);
	$data[]=$item;
	$rs->movenext();
}
$data=SortArray($data,"order");
foreach($data as $rs)
{
	if ($_5hFlag)
    {
        if (isset($g_betname_3or5[$rs['bettype']]))
        {
            $list .= "<tr class=\"td2\">";
            $list .= "<td nowrap class=\"gtdnum\">" . $g_betname_3or5[$rs['bettype']] . "</td>";
            if ($rs['amount2'] == 0)
            {
                $list .= "<td nowrap align=\"right\"> - </td>";
                $list .= "<td nowrap align=\"right\"> - </td>";
                $list .= $listNullTd;
            }
            else
            {
                if ($disk1Flag)
                {
                    $list .= "<td nowrap align=\"right\">" . round(100 - $rs['back1'], 2) . "</td>";
                }
                if ($disk2Flag)
                {
                    $list .= "<td nowrap align=\"right\">" . round(100 - $rs['back2'], 2) . "</td>";
                }
                if ($disk3Flag)
                {
                    $list .= "<td nowrap align=\"right\">" . round(100 - $rs['back3'], 2) . "</td>";
                }
                if ($disk4Flag)
                {
                    $list .= "<td nowrap align=\"right\">" . round(100 - $rs['back4'], 2) . "</td>";
                }
                $list .= "<td nowrap align=\"right\">" . number_format($rs['amount1']) . "</td>";
                $list .= "<td nowrap align=\"right\">" . number_format($rs['amount2']) . "</td>";
            }
            $list .= "</tr>";
        }
    }
	elseif ($g_gametype_3d[$gametype]['type'] == 4)
	{
		$list .= "<tr >";
        $list .= "<td nowrap class=\"gtdnum\">" . $g_betname_3or5[$rs['bettype']] . "</td>";
        if ($rs['amount2'] == 0)
        {
            $list .= "<td nowrap align=\"left\"> - </td>";
            $list .= "<td nowrap align=\"left\"> - </td>";
            $list .= $listNullTd;
        }
        else
        {
            if ($disk1Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back1'], 2) . "</td>";
            }
            if ($disk2Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back2'], 2) . "</td>";
            }
            if ($disk3Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back3'], 2) . "</td>";
            }
            if ($disk4Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back4'], 2) . "</td>";
            }
            $list .= "<td nowrap align=\"left\">" . number_format($rs['amount1']) . "</td>";
            $list .= "<td nowrap align=\"left\">" . number_format($rs['amount2']) . "</td>";
        }
        $list .= "</tr>";	
	}
    else if (isset($g_betname_3or5[$rs['bettype'] . "_" . $rs['subid']]))
    {
        $list .= "<tr >";
        $list .= "<td nowrap class=\"gtdnum\">" . $g_betname_3or5[$rs['bettype'] . "_" . $rs['subid']] . "</td>";
        if ($rs['amount2'] == 0)
        {
            $list .= "<td nowrap align=\"left\"> - </td>";
            $list .= "<td nowrap align=\"left\"> - </td>";
            $list .= $listNullTd;
        }
        else
        {
            if ($disk1Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back1'], 2) . "</td>";
            }
            if ($disk2Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back2'], 2) . "</td>";
            }
            if ($disk3Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back3'], 2) . "</td>";
            }
            if ($disk4Flag)
            {
                $list .= "<td nowrap align=\"left\">" . round(100 - $rs['back4'], 2) . "</td>";
            }
            $list .= "<td nowrap align=\"left\">" . number_format($rs['amount1']) . "</td>";
            $list .= "<td nowrap align=\"left\">" . number_format($rs['amount2']) . "</td>";
        }
        $list .= "</tr>";
    }
}
if ($list == "")
{
    $list = "<tr class=\"row1\"><td colspan=\"" . $colspanI . "\">查无" . $tblName . "资料</td></tr>";
}
//$tpl->load("main", "info.htm");
$tpl->load( array("menu" => ($gametype==24?'pk':'ssc')."_menu.htm","main" => "info.htm") );
$tpl->set("gametype",$gametype);
$tpl->show( "menu" );

$tpl->set("amount", number_format($curruser['amount']));
$tpl->set(array("amountlist" => $list, "account" => $curruser['account'], "name" => $curruser['name'], "disk" => $currDisk, "alertmsg" => $alertmsg, "gametypeStr" => $tblName, "backTDList" => $backTDList, "gametype" => $gametype, "ganetype_color" => "bgClc_{$gametype}"));
$ui->header();
$ui->showNews3D($curruser['acl'],1);
$tpl->show("main");
$ui->footer();
echo "\r\n\r\n";
?>